home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / games1 / tahckv10.lha / TA-Hack / source / Hack.c < prev    next >
C/C++ Source or Header  |  1996-04-13  |  2KB  |  81 lines

  1. #include "FindTaskExt.h"
  2.  
  3. UBYTE *LIVES[2];
  4. ULONG *MONEY[2];
  5.  
  6. ULONG len[5];
  7. ULONG AGAlen[5] = {243624, 292168, 12564, 497192, 526544};
  8. ULONG ECSlen[5] = {199084, 313548, 20120, 430200,  72284};
  9. ULONG *addrs[5];
  10.  
  11. BYTE found=0; /* 0=nothing, 1=AGA, 2=ECS, 3=5 hunks, 4=min 2nd hunk, 5=more than 5 hunks */
  12.  
  13. #define b2c(bptr,type) ( (type) ((ULONG)(bptr) << 2))
  14.  
  15. static char *findTA(void){
  16.     ULONG type = FT_PROCESS | FT_COMMAND;
  17.     struct Process *TA = (struct Process *)FindTaskExt("AB",FALSE,&type);
  18.     ULONG *segs;
  19.     UBYTE *bseg;
  20.     char i;
  21.  
  22.     if(!TA)
  23.         return("Could´nt find TowerAssault in memory.");
  24.     if(type == FT_PROCESS){
  25.         segs = (ULONG *)(TA->pr_SegList << 2);
  26.         if(!segs)
  27.             return("Could´nt find SegList.");
  28.         segs = (ULONG *)(segs[3] << 2);
  29.     }else{ // type == FT_COMMAND
  30.        segs = b2c(b2c(TA->pr_CLI, struct CommandLineInterface *)->cli_Module, ULONG *);
  31.     }
  32.     for(i=0; i<5; i++){
  33.         if(!segs){
  34.             sprintf(err,"Could´nt find %s hunk.",i==0?"1st":(i==1?"2nd":(i==2?"3rd":(i==3?"4th":"5th"))));
  35.             if(i>=2 && len[1]>=0x1570)
  36.                 found = 4;
  37.             return(err);
  38.         }
  39.         len[i] = segs[-1];
  40.         addrs[i] = segs+1;
  41.         segs = (ULONG *)(segs[0] << 2);
  42.     }
  43.     if(segs){
  44.         found = 5;
  45.         return("Found 6th hunk, what sould I do?");
  46.     }
  47.     segs = addrs[1];
  48.     bseg = (UBYTE *)segs;
  49.     LIVES[0] = &bseg[0x12ed];
  50.     MONEY[0] = &segs[0x136c/4];
  51.     LIVES[1] = &bseg[0x14ed];
  52.     MONEY[1] = &segs[0x156c/4];
  53.     for(i=0; i<5 && len[i]==AGAlen[i]; i++);
  54.     if(i==5){
  55.         found = 1;
  56.         return("Found TowerAssault AGA.");
  57.     }else{
  58.         for(i=0; i<5 && len[i]==ECSlen[i]; i++);
  59.         if(i==5){
  60.             found = 2;
  61.             return("Found TowerAssault ECS.");
  62.         }
  63.     }
  64.     found=3;
  65.     return("Found a programm, unidentified.");
  66. }
  67.  
  68. static ULONG dummy;
  69.  
  70. void setlives(int plr, APTR str_lives){
  71.     get(str_lives, MUIA_String_Integer, &dummy);
  72.     *LIVES[plr] = dummy;
  73. }
  74.  
  75. void setmoney(int plr, APTR str_money){
  76.     get(str_money, MUIA_String_Integer, &dummy);
  77.     if(*MONEY[0] == *MONEY[1])
  78.         *MONEY[1-plr] = dummy;
  79.     *MONEY[plr] = dummy;
  80. }
  81.